/* $Id: AppMetaDataDelegateImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.delegate.provider;

import java.io.Serializable;
import java.util.List;

import ae.pcfc.etks.online.common.ConstantsCommon.WFProcessType;
import ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate;
import ae.pcfc.etks.online.common.facade.AppMetaDataFacade;
import ae.pcfc.etks.online.common.facade.ServiceFacade;
import ae.pcfc.etks.online.common.vo.AdminApprovalVO;
import ae.pcfc.etks.online.common.vo.AppMetaDataDetailVO;
import ae.pcfc.etks.online.common.vo.AppMetaDataVO;
import ae.pcfc.etks.online.common.vo.LabelVO;
import ae.pcfc.etks.online.common.vo.WorkflowRequestSearchCriteriaVO;
import ae.pcfc.etks.online.common.vo.WorkflowRequestVO;

public class AppMetaDataDelegateImpl extends BaseDelegateImpl  implements AppMetaDataDelegate {
    	/*
	 * Here we coordinate between the Facade service which handles DB entities
	 * and the WF both will be looked up with service locator normally we will
	 * have 1-1 relationship between the delegate and the facade and 1-1
	 * relationship between the delegate and the WF service which means for
	 * CompanyRegistrationDelegate there will be ClientRegistrationFacade &
	 * CompanyRegistrationWF validations that related to DB vs WF are maintained
	 * here ie user cannot issue a new request while he already have a request
	 * in the wf Exception are translated in to business exception
	 */
	
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 6361789617854401995L;

	/**
	 * loadAppMetaData
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadAppMetaData(java.lang.String)
	 * 
	 */
	public AdminApprovalVO loadAppMetaData(String applicationId) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataByPrimaryKey(applicationId);
	}

	/**
	 * loadAppMetaDataByUserId
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadAppMetaDataByUserId(java.lang.Long)
	 * 
	 */
	public List<AppMetaDataDetailVO> loadAppMetaDataByUserId(Long id) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataByUserId(id);
	}

	/**
	 * loadAppMetaDataByClientRefNo
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadAppMetaDataByClientRefNo(java.lang.String)
	 * 
	 */
	public AppMetaDataDetailVO loadAppMetaDataByClientRefNo(String refNo) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataByClientRefNo(refNo);
	}

	/**
	 * loadCompletedAppMetaDataByUserId
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadCompletedAppMetaDataByUserId(java.lang.Long)
	 * 
	 */
	public List<AppMetaDataDetailVO> loadCompletedAppMetaDataByUserId(Long id) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findCompletedAppMetaDataByUserId(id);
	}

	/**
	 * createApplicationRequest
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#createApplicationRequest(ae.pcfc.etks.online.common.vo.AppMetaDataVO)
	 * 
	 */
	public void createApplicationRequest(AppMetaDataVO appMetaDataVO) {
		serviceLocator.getFacadeService(AppMetaDataFacade.class).addApplicationRequest(appMetaDataVO);
	}

	/**
	 * updateApplicationRequest
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#updateApplicationRequest(ae.pcfc.etks.online.common.vo.AppMetaDataVO)
	 * 
	 */
	public void updateApplicationRequest(AppMetaDataVO appMetaDataVO) {
		serviceLocator.getFacadeService(AppMetaDataFacade.class).updateApplicationRequest(appMetaDataVO);
	}

	/**
	 * updateApplicationStatus
	 * 
	 * @param applicationId
	 * @param statusEn
	 * @param statusAr
	 * void
	 */
	public void updateApplicationStatus(String applicationId, String statusEn,String statusAr) {
		serviceLocator.getFacadeService(AppMetaDataFacade.class).updateApplicationStatus(applicationId, statusEn, statusAr);
	}

	/**
	 * loadApplicationRequest
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadApplicationRequest(java.lang.String)
	 * 
	 */
	public AppMetaDataVO loadApplicationRequest(String applicationId) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).getApplicationRequest(applicationId);
	}

	/**
	 * searchApplicationRequestsByProcessCode
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#searchApplicationRequestsByProcessCode(ae.pcfc.etks.online.common.ConstantsCommon.WFProcessType)
	 * 
	 */
	public List<AppMetaDataVO> searchApplicationRequestsByProcessCode(WFProcessType processType) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).searchApplicationRequestsByProcessCode(processType);
	}

	/**
	 * searchApplicationRequestsByInitiator
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#searchApplicationRequestsByInitiator(java.lang.String)
	 * 
	 */
	public List<AppMetaDataVO> searchApplicationRequestsByInitiator(String username) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).searchApplicationRequestsByInitiator(username);
	}

	/**
	 * searchApplicationRequestsByApplicationDate
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#searchApplicationRequestsByApplicationDate(java.lang.String)
	 * 
	 */
	public List<AppMetaDataVO> searchApplicationRequestsByApplicationDate(String date) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).searchApplicationRequestsByApplicationDate(date);
	}

/*	public List<AppMetaDataVO> searchApplicationRequestsByUserId(Long userId) {
		// TODO Auto-generated method stub
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).searchApplicationRequestsByUserId(userId);
	}*/

	/**
	 * searchAppMetaDataVOByExample
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#searchAppMetaDataVOByExample(ae.pcfc.etks.online.common.vo.AppMetaDataVO)
	 * 
	 */
	public List<AppMetaDataVO> searchAppMetaDataVOByExample(AppMetaDataVO appMetaDataVO) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataVOByExample(appMetaDataVO);
	}

	/**
	 * searchAppMetaDataDetailVOByExample
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#searchAppMetaDataDetailVOByExample(ae.pcfc.etks.online.common.vo.AppMetaDataDetailVO)
	 * 
	 */
	public List<AppMetaDataDetailVO> searchAppMetaDataDetailVOByExample(AppMetaDataDetailVO appMetaDataDetailVO) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataDetailVOByExample(appMetaDataDetailVO);
	}

/*	public List<AppMetaDataDetailVO> loadCompletedAppMetaDataByUserId(AppMetaDataDetailVO appMetaDataDetailVO) {
		// TODO Auto-generated method stub
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findCompletedAppMetaDataByUserId(appMetaDataDetailVO);
	}
*/
	/**
	 * SearchApplicationRequests
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#SearchApplicationRequests(ae.pcfc.etks.online.common.vo.AppMetaDataVO)
	 * 
	 */
	public List<AppMetaDataVO> SearchApplicationRequests(AppMetaDataVO appMetaDataVO){
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataVOByExample(appMetaDataVO);
	}

	/**
	 * loadAppMetaDataByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.delegate.AppMetaDataDelegate#loadAppMetaDataByUserName(java.lang.String)
	 * 
	 */
	public List<AppMetaDataDetailVO> loadAppMetaDataByUserName(String strUserName) {
		return serviceLocator.getFacadeService(AppMetaDataFacade.class).findAppMetaDataByUserName(strUserName);
	}

	public List<WorkflowRequestVO> searchWorkflowRequests(WorkflowRequestSearchCriteriaVO searchCriteria) {
		return this.serviceLocator.getFacadeService(AppMetaDataFacade.class).findWorkflowRequests(searchCriteria);
	}

	public List<LabelVO> searchRequestStatus(String searchString) {
		return this.serviceLocator.getFacadeService(AppMetaDataFacade.class).searchRequestStatus(searchString);
	}

}
